<?php $this->load->view('common/head');?>
<form class="form-horizontal" name="add" id="add" action="<?php echo $this->input->server('REQUEST_URI'); ?>" method="post">
  <input type="hidden" name="id" id="id" value="<?=isset($matchingData) ? $matchingData['id'] : ''?>">
  <input type="hidden" name="procId" id="procId" value="<?=$procId?>">
  <input type="hidden" name="projectId" id="projectId" value="<?=$projectId?>">
  <table class="table table-condensed table-bordered mb27" style="width: 350px; margin:0 auto;" cellspacing="1">
    <tbody>
      <tr>
        <td class="bg-primary col-md-4">类型</td>
        <td>
          <select required class="form-control" placeholder="" id="type" name="type">
            <option value="">请选择</option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4">费用项目描述</td>
        <td>
          <select required class="form-control" placeholder="" id="descType" name="descType">
          <option value="">请选择</option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4"></td>
        <td>
          <input type="input" class="form-control" name="descTypeAlias" id="descTypeAlias" value="<?=(float)$matchingData['descTypeAlias'] ? $matchingData['descTypeAlias'] : ''?>" placeholder="其它费用项目描述">
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4">活动开始时间</td>
        <td>
          <input type="input" required class="form-control" onFocus="WdatePicker({minDate:'<?=date("Y-m-d", strtotime($carshowData['startTime'].' -1 week'))?>',maxDate:'#F{$dp.$D(\'endTime\')||\'<?=date("Y-m-d", strtotime($carshowData['endTime'].' +1 week'))?>\'}'})" name="startTime" id="startTime" value="<?=$matchingData['startTime']?>" placeholder="开始时间">
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4">活动结束时间</td>
        <td>
          <input type="input" required class="form-control" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')||\'<?=date("Y-m-d", strtotime($carshowData['startTime'].' -1 week'))?>\'}',maxDate:'<?=date("Y-m-d", strtotime($carshowData['endTime'].' +1 week'))?>'})" name="endTime" id="endTime" value="<?=$matchingData['endTime']?>" placeholder="结束时间">
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4">预算费用</td>
        <td>
          <input type="number" required min="0" step="0.01" class="form-control" name="budgetApply" id="budgetApply" value="<?=(float)$matchingData['budgetApply'] ? $matchingData['budgetApply'] : ''?>" placeholder="预算费用">
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-4">备注</td>
        <td>
          <textarea class="form-control" name="remarks" id="remarks" rows="3"><?=isset($matchingData) ? $matchingData['remarks'] : ''?></textarea>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
          <button type="submit" class="btn btn-default btn-primary">保存</button>
          <button type="button" onclick="closeWindow()" class="btn btn-default btn-primary">取消</button>
        </td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/javascript" src="public/js/commonOffline.js"></script>
<script type="text/javascript">
$(function(){
  initValidation();
  offlineDetailTypeDisplay('type', <?=isset($matchingData) ? $matchingData['type'] : 0?>);
  matchingDescTypeDisplay(<?=isset($matchingData) ? $matchingData['type'] : 0?>,<?=isset($matchingData) ? $matchingData['descType'] : 0?>);
  descTypeAliasDisplay(<?=isset($matchingData) ? $matchingData['descType'] : ''?>);
  $("#type").change(function(){
    matchingDescTypeDisplay(this.value);
    descTypeAliasDisplay();
    initValidation();
  });
  $("#descType").change(function(){
    descTypeAliasDisplay(this.value);
    initValidation();
  });
});
//初始化验证
function initValidation(){
  $('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
  $('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
      preventSubmit:false,
      submitSuccess: function (form, event) {
           event.preventDefault();
           ajaxFormSubmit('add');
       },
       submitError: function (form, event, errors) {
         event.preventDefault();
         }
    });
}
</script>
<?php $this->load->view('common/foot');?>